package com.jgy.策略And工厂模式;

import com.jgy.策略模式.CountPrice;
import org.apache.commons.lang3.StringUtils;

/**
 * @author 姜光远
 * @date 2022/12/15 11:14
 */
public class Context {
    public static String toPayHtml(String code,double prices,int num) {

        if (StringUtils.isBlank(code)) {
            return "code不能为空...";
        }
        CountPrice payStrategy = StrategyFactory.getCountPrice(code);
        System.out.println(payStrategy);
        if (payStrategy == null) {
            return "没有找到具体的策略...";
        }
        double price = payStrategy.getPrice(prices,num);

        return String.valueOf(price);
    }
}
